#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

const int N=1e5+10;
int arr[N];

int main()
{
	int m, n; cin>>m>>n;
	for(int i=1; i<=m; i++) cin>>arr[i];
	sort(arr+1, arr+1+m);
	long long ret=0;
	arr[0]=-1e9;
	while(n--)
	{
		int x; cin>>x;
		auto l=lower_bound(arr+1, arr+m+1, x);
		int i=l-arr;
		int j=i-1;
		ret+=min(abs(arr[i]-x), abs(arr[j]-x));
	}
	cout<<ret; 
	return 0;
}
